import { _get, _post } from "../../../utils/request";
import util from "../../../utils/util";
const app = getApp();

import { debounce, throttle } from "../../../utils/debounce";
Page({
    data: {
        tabs: [{
                title: "待确认",
                badgeType: "text",
                name: "xx",
                // badgeText: "6",
            },
            {
                title: "待检测",
                badgeType: "dot",
                name: "aa",
            },
            {
                title: "待校核",
                badgeType: "dot",
                name: "aa",
            }
        ],
        activeTab: 0,
        myconfirm: [],
        mytest: [],
        myreview: [],
    },
    jump_confirm(e) {
        console.log("e", e);
        app.confirmId = e.currentTarget.id;
        dd.navigateTo({
            url: "/pages/confirm/confirm",
        });
    },
    jump_test_confirm(e) {
        // console.log("e", e);
        app.confirmId = e.currentTarget.id;
        app.test_id = e.currentTarget.id;
        dd.navigateTo({
            url: "/pages/mytest/test_confirm/test_confirm",
        });
    },
    jump_review(e) {
        app.review_id = e.currentTarget.id;
        dd.navigateTo({
            url: "/pages/review/review",
        });
    },
    //使用防抖节流示例
    // test: debounce((e) => {
    //     console.log(e);
    // }, 1000),
    // test: throttle((e) => {
    //     console.log(e);
    // }, 1500),
    handleTabClick({ index }) {
        this.setData({
            activeTab: index,
        });
    },
    //获取待确认列表
    getConfirm(keyword = '') {
        let params = {
            userId: app.userId,
            workerName: keyword,
        };
        _get(`/vbizMain/selectWait`, params).then((res) => {
            console.log("confirm", res);
            this.setData({
                myconfirm: res.data,
            });
        });
    },
    //获取待检测列表
    getTest(keyword = '') {
        let params = {
            userId: app.userId,
            workerName: keyword,
        };

        _get(`/vbizMain/selectTest`, params).then((res) => {
            // console.log("test", res);
            this.setData({
                mytest: res.data,
            });
        });
    },
    //获取待校核列表
    getReview(keyword = '') {
        let params = {
            userId: app.userId,
            workerName: keyword,
        };

        _get(`/vbizMain/selectRecheck`, params).then((res) => {
            // console.log("test", res);
            this.setData({
                myreview: res.data,
            });
        });
    },
    //搜索功能待确认
    search1(e) {
        this.getConfirm(e)
    },
    //搜索功能待检测
    search2(e) {
        console.log(e);
        this.getTest(e)
            // let params = {
            //     userId: 3,
            //     workerName: e,
            // };
            // _get(`/myTest/selectTest`, params).then((res) => {
            //     console.log("test", res);
            //     this.setData({
            //         mytest: res.data,
            //     });
            // });
    },
    //搜索功能待校核

    onLoad() {
        dd.setNavigationBar({
            title: "我的工单",
            backgroundColor: "#142e4f",
            success() {},
            fail() {},
        });
        this.getTest();
        this.getConfirm();
        this.getReview()
    },
});